<?php
$c = 0;
$percent = 9.99;

foreach ($groups as $group => $services): $c++;
    ?>
    <dl class="widget">
        <dt class="no-strong">        
        <?php
        if ($c == 1) {
            if (Controller::$pageData['_parents']['brand']['pageId'] == 357)
                echo '<p class="differ" style="
    color: rgb(5, 162, 85);
    font-size: 22px;text-align: center;
">Цена указана только за услугу без учета стоимости запчастей. <br>
 Позвоните нам для подробностей.</p>
                <br />';
            elseif ((!empty(Controller::$pageData['pageGroup']) && Yii::app()->user->isGuest) || Yii::app()->user->isGuest) {
                echo '<p class="differ" style="
                            color: rgb(5, 162, 85);
                            font-size: 22px;text-align: center;
                        ">Цена указана только за услугу без учета стоимости запчастей. <br>
                         Позвоните нам для подробностей.</p>
                <br />';
            } else
                echo 'Цена указана с учетом стоимости запчастей и всех работ.
                <span class="yellow-background">Все запчасти оригинальные.</span><br />';
        }
        ?>

        <hr />
        <span class="price-group"><?php echo $group; ?></span>
        </dt>
        <dd>
            <div class="hardware-repair">
                <?php if ($c > 1) echo '<noindex>'; ?>
                <ul class="hardware-repair__title">
                    <li class="hardware-repair__name">Наименование услуги</li>
                    <li class="hardware-repair__price">Цена</li>
                    <li class="hardware-repair__warranty">Гарантия</li>
                    <li class="hardware-repair__period">Срок</li>
                    <li class="hardware-repair__button">&nbsp;</li>
                </ul>

                <?php if ($c > 1) echo '</noindex>'; ?>
                <ul class="hardware-repair__info">
                    <?php
                    $counter = 0;
                    foreach ($services as $key => $value):
                        ?>
                        <li class="hardware-repair__info__item <?php echo $icons[$value['available']]; ?> <?php
                        if ($counter == 1) {
                            echo 'active';
                        } else {
                            $counter = 0;
                        } $counter++;
                        ?>" title="<?php //echo $titles[$value['available']];      ?>" >
                            <ul>
                                <li class="hardware-repair__name" data-action="<?php echo '/main/ajax/order?pageUrl=' . Yii::app()->request->hostInfo . '/' . Controller::$pageData['pageUrl'] . '&h1=' . Controller::$pageData['pageTitle'] . '&serviceTitle=' . CHtml::encode($value['serviceTitle']) . '&tip=' . Controller::$pageData['_parents']['category']['pageTitle'] . '&brend=' . $data['_parents']['brand']['pageTitle'] . '&model=' . $data['pageTitle'] . '&sena=' . CHtml::encode($value['price']); ?>">
                                    <span class="hardware-repair__name__link" id="click-<?php echo $value['serviceId']; ?>">
                                        <?php //if (!empty($value['serviceDescription'])) echo '<noindex>';         ?>										
                                        <span>
                                            <span class="strong"><?php echo $value['serviceTitle']; ?></span> 

                                        </span>
                                        <?php //if (!empty($value['serviceDescription'])) echo '</noindex>';         ?>										
                                    </span>    
                                </li>
                                <li class="hardware-repair__price" >
                                    <?php
                                    $regionId = Yii::app()->session['userRegion']['id'];
                                    $exids = array(31, 33, 34);
                                    if ($regionId != 1)
                                        $exids = array_merge($exids, array(32));
                                    $aEx = 67;
                                    $eprice = ($value['price'] / $aEx * $exchange);
                                    $eprice = (int) ($eprice / 100) * 100 + 90;
                                    $dprice = ($data['pageGroup'] == 'course' && in_array($value['serviceId'], $exids) ? $eprice : Controller::numberFormat($value['price']));
                                    if (filter_var($value['price'], FILTER_VALIDATE_INT)) {
                                        $aPrice = $percent * (int) $value['price'] / 100 + $value['price'];
                                        echo '<a href="/main/ajax/loadForm?formName=buying-services-st&modelName=buyServiceForm&service=' . urlencode($value['serviceTitle']) . '&price=' . urlencode($value['price']) . '&priceOld=' . urlencode((50 * (intval($aPrice / 50) + 1))) . '&bim=' . urlencode($data['_parents']['brand']['pageTitle'] . " " . $data['pageTitle']) . '" class="fancybox fancybox.ajax buyServiceForm"><span class="price-group">Акция!</span></a><br style=" margin-bottom: 5px;"> ';
                                        echo $dprice . '&nbsp;<span class="hyphen"></span><span class="ruble">p</span><br>';
                                        echo '<span class="chz">';
                                        echo Controller::numberFormat(50 * (intval($aPrice / 50) + 1)) . '&nbsp;<span class="hyphen"></span><span class="ruble">p</span>';
                                        echo '</span>';
                                    } elseif (empty($value['price'])) {
                                        echo 'Звоните';
                                    } else {
                                        echo $value['price'];
                                    }
                                    ?>                             
                                </li>
                                <li class="hardware-repair__warranty"><?php echo $value['serviceWarranty']; ?></li>
                                <li class="hardware-repair__period width-10"><?php echo $value['serviceTime']; ?></li>
                                <noindex>
                                    <li class="hardware-repair__button  width-20">
                                        <span class="global-button green-bg price-button">
                                            <a id="service-<?php echo $value['serviceId']; ?>" href="/main/ajax/loadForm?formName=buying-services&modelName=buyServiceForm" class="fancybox fancybox.ajax">Купить услугу</a>
                                        </span>
                                        <?php if (strpos(Controller::$pageData['pageUrl'], 'remont-telefonov') === false && strpos(Controller::$pageData['pageUrl'], 'remont-planshetov') === false && strpos(Controller::$pageData['pageUrl'], 'remont-noutbukov') === false): ?>
                                            <br>
                                        <noindex><a class="fancybox fancybox.ajax" style="font: 14px 'proxima_nova_rgbold',sans-serif;" href="/main/ajax/loadForm?formName=repairer&modelName=RepairerForm" rel="nofollow">Вызвать мастера на дом</a></noindex>
                                    <?php endif; ?>    
                                    </li>
                                </noindex>
                            </ul>
                            <script>
                                $('li.hardware-repair__button span.global-button.green-bg').on('click', 'a', function()
                                {
                                    localStorage.setItem("mobi03.buy_action", $(this).parents('li.hardware-repair__info__item').find('li.hardware-repair__name').data("action"));
                                });
                                $('.buyServiceForm').on('click', function()
                                {
                                    localStorage.setItem("mobi03.buy_action", $(this).parents('li.hardware-repair__info__item').find('li.hardware-repair__name').data("action"));
                                });
                            </script>
                            <div class="hardware-repair__description">

                                <noindex>
                                    <div class="global-form">
                                        <h3>Оставьте онлайн заявку</h3>
                                        <?php
                                        $form = $this->beginWidget('CActiveForm', array(
                                            'id' => 'model-form-' . $value['serviceId'],
                                            'action' => '/main/ajax/order?pageUrl=' . Yii::app()->request->hostInfo . '/' . Controller::$pageData['pageUrl'] . '&h1=' . Controller::$pageData['pageTitle'] . '&serviceTitle=' . $value['serviceTitle'] . '&tip=' . Controller::$pageData['_parents']['category']['pageTitle'] . '&brend=' . $data['_parents']['brand']['pageTitle'] . '&model=' . $data['pageTitle'] . '&sena=' . $value['price'],
                                            'enableClientValidation' => false,
                                            'htmlOptions' => array('class' => 'buy__service__form'),
                                        ));
                                        ?>
                                        <div style="display: none">
                                            <?php echo $form->error($model, 'userName'); ?>
                                            <?php echo $form->error($model, 'userPhone'); ?>
                                        </div>
                                        <fieldset>
                                            <p>Закажите ремонт до 
                                                <strong><?php echo (int) date('d', time() + 3600 * 24), ' ', Yii::app()->locale->getMonthName(date('n', time() + 3600 * 24)); ?></strong> и получите скидку <strong><?php echo isset(Yii::app()->session['skidka']) && !empty(Yii::app()->session['skidka']) ? Yii::app()->session['skidka'] . '%' : '5%' ?></strong></p>
                                            <div class="wrap-bg">
                                                <div class="type-text">
                                                    <?php echo $form->textField($model, 'userName', array('placeholder' => 'Ваше имя', 'id' => 'buyServiceForm_userName_' . $value['serviceId'])); ?>
                                                </div>
                                            </div>    
                                        </fieldset>
                                        <fieldset>
                                            <div class="wrap-bg">
                                                <div class="type-text">
                                                    <?php echo $form->textField($model, 'userPhone', array('placeholder' => 'Ваш телефон', 'class' => 'masked-phone', 'id' => 'buyServiceForm_userPhone_' . $value['serviceId'])); ?>
                                                </div>
                                            </div>    
                                        </fieldset>
                                        <fieldset style="display: none">
                                            <div class="wrap-bg">
                                                <div class="type-text">
                                                    <?php echo $form->textField($model, 'userEmail', array('placeholder' => 'Ваш E-mail', 'id' => 'buyServiceForm_userEmail_' . $value['serviceId'])); ?>
                                                </div>
                                            </div>    
                                        </fieldset>
                                        <fieldset style="display: none;">
                                            <div class="wrap-bg">
                                                <div class="select">
                                                    <?php echo $form->dropdownList($model, 'city', $regions); ?>												
                                                </div>
                                            </div>    
                                        </fieldset>
                                        <fieldset>
                                            <div class="choice-courier">
                                                <div class="checkbox <?php echo ($model->courier == 1 ? ' open ' : ''); ?>">
                                                    <?php echo $form->checkBox($model, 'courier', array('id' => 'free-courier-' . $value['serviceId'], 'value' => 1, 'uncheckValue' => 0)); ?>
                                                    <label for="free-courier-<?php echo $value['serviceId'] ?>">
                                                        <span class="checkbox__box">
                                                            <span class="checkbox__box__inner">&nbsp;</span>
                                                        </span>    
                                                        <span class="checkbox__text">Нужен бесплатный курьер</span>
                                                    </label>
                                                    <div class="wrap-bg">
                                                        <div class="type-text">
                                                            <?php echo $form->textField($model, 'userAddress', array('placeholder' => 'Введите ваш адрес', 'id' => 'buyServiceForm_userAddress_' . $value['serviceId'])); ?>
                                                        </div>
                                                    </div>  
                                                </div> 
                                            </div> 
                                        </fieldset>
                                        <fieldset>
                                            <p>Наш менеджер свяжется с вами в ближайшие минуты</p>
                                            <div class="type-submit">
                                                <?php echo CHtml::submitButton('Заказать'); ?>		
                                            </div> 
                                        </fieldset>
                                        <?php $this->endWidget(); ?>
                                    </div>  
                                </noindex>
                            </div>    
                        </li>
                        <script>
                            jQuery('#model-form-<?php echo $value['serviceId']; ?>').yiiactiveform(
                                    {
                                        'validateOnSubmit': true,
                                        'afterValidate': function(form, data, hasError)
                                        {
                                            if (!hasError)
                                            {
                                                var courier = "without courier";
                                                var checkbox = $("form#model-form-30 div.choice-courier>div.checkbox");

                                                if (checkbox.hasClass("open"))
                                                {
                                                    courier = "courier";
                                                }
                                                mobi03.sendGoogleStatic("Order-online-from-price-form", courier, window.location.href);

                                                $.ajax(
                                                        {
                                                            type: "POST",
                                                            url: form[0].action,
                                                            data: $(form).serialize(),
                                                            success: function(ret)
                                                            {
                                                                $(".fancybox-close").trigger("click");
                                                                var data = JSON.parse(ret);
                                                                mobi03.showMessage(data.message.title, data.message.desc);
                                                            }
                                                        });
                                            }
                                        },
                                        'attributes': [
                                            {
                                                'id': 'buyServiceForm_userName_<?php echo $value['serviceId']; ?>',
                                                'inputID': 'buyServiceForm_userName_<?php echo $value['serviceId']; ?>',
                                                'errorID': 'buyServiceForm_userName_em__<?php echo $value['serviceId']; ?>',
                                                'model': 'buyServiceForm',
                                                'name': 'userName',
                                                'enableAjaxValidation': false,
                                                'clientValidation': function(value, messages, attribute)
                                                {
                                                    if (jQuery.trim(value) == '')
                                                    {
                                                        messages.push("\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u043e\u043b\u0435 \u00abUser Name\u00bb.");
                                                    }

                                                }
                                            },
                                            {
                                                'id': 'buyServiceForm_userPhone_<?php echo $value['serviceId']; ?>',
                                                'inputID': 'buyServiceForm_userPhone_<?php echo $value['serviceId']; ?>',
                                                'errorID': 'buyServiceForm_userPhone_em_<?php echo $value['serviceId']; ?>',
                                                'model': 'buyServiceForm',
                                                'name': 'userPhone',
                                                'enableAjaxValidation': false,
                                                'clientValidation': function(value, messages, attribute)
                                                {
                                                    if (jQuery.trim(value) == '')
                                                    {
                                                        messages.push("\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u043e\u043b\u0435 \u00abUser Phone\u00bb.");
                                                    }
                                                }
                                            },
                                            {
                                                'id': 'buyServiceForm_userAddress_<?php echo $value['serviceId']; ?>',
                                                'inputID': 'buyServiceForm_userAddress_<?php echo $value['serviceId']; ?>',
                                                'errorID': 'buyServiceForm_userAddress_em_<?php echo $value['serviceId']; ?>',
                                                'model': 'buyServiceForm',
                                                'name': 'userPhone',
                                                'enableAjaxValidation': false,
                                                'clientValidation': function(value, messages, attribute)
                                                {
                                                    if (jQuery.trim(value) == '' && $("form#model-form-<?php echo $value['serviceId']; ?> div.choice-courier>div.checkbox").hasClass("open"))
                                                    {
                                                        messages.push("\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u043e\u043b\u0435 \u00abUser Address\u00bb.");
                                                    }
                                                }
                                            }
                                        ],
                                        'errorCss': 'error'
                                    });
                        </script>
                    <?php endforeach; ?>
                </ul>
                <br><br>

            </div>   
        </dd>
    </dl>  
<?php endforeach; ?>
<dl class="widget">
    <dt class="no-strong">
    <?php
    if (Controller::$pageData['_parents']['category']['pageId'] != 1) {
        echo 'Цена указана без учета стоимости запчастей. Звоните для подробностей.<br />';
    }
    ?>

    </dt>
</dl>
<style>
    .chz {
        text-decoration: line-through;
        -moz-text-decoration-color: red;
        text-decoration-color: red;
        text-align: justify;
    }
    .buyServiceForm {
        text-decoration: none;
        border-bottom: 1px dashed;

    }
    ul.social-networks {
        width: 550px;
    }
    ul.social-networks li {
        padding-right: 10px;
        float: left;
        list-style: none;

    }
    .like-text {
        -moz-text-size-adjust: none;
        color: #636363;
        font: 500 14px 'Exo 2',sans-serif !important;
        padding-top: 10px;
    }

    .like-text strong {        
        font: 700 14px 'Exo 2',sans-serif !important;        
    }
    /*    .fb_iframe_widget {
            width: 102px !important; 
        }
        #vk_like {
            width: 131px !important; 
        }*/
    #twitter-widget-0 {
        width: 80px !important; 
    }
    .cursor-pointer {
        cursor: pointer;
    }

    .search {
        border: medium dashed #b1d7ea !important;
        border-radius: 7px !important;
    }

</style>
<script src="<?php echo Yii::app()->theme->baseUrl; ?>/assets/js/jquery.cookie.js"></script>
<script>


                            $(document).ready(function() {
                                if (document.location.hash != "") {
                                    var hash = document.location.hash;
                                    hash = hash.split('#');
                                    hash = hash[1];
                                    $("#click-" + hash).trigger("click");
                                    $("#service-" + hash).parents("li.hardware-repair__info__item").addClass("search");
                                    $("#service-" + hash).parents("li.hardware-repair__info__item").addClass("open");
                                    $("html, body").animate({
                                        scrollTop: $("#click-" + hash).offset().top - 40
                                    }, 1000);
                                }
                                $('iframe#vkwidget1_tt').remove();
                            });
</script>

<style>
    .ui-autocomplete {
        max-height: 200px;
        overflow-y: auto;
        /* prevent horizontal scrollbar */
        overflow-x: hidden;
        /* add padding to account for vertical scrollbar */
        padding-right: 20px;
    }
    /* IE 6 doesn't support max-height
     * we use height instead, but this forces the menu to always be this tall
     */
    * html .ui-autocomplete {
        height: 100px;
    }
    .icon-info {
        font-size: 18px;
    }
    .differ {
        color: rgb(217, 72, 137);
        font-size: 22px;

    }

</style>